import { Component } from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';

import {Address, states, Hero} from './data-model';

@Component({
  selector: 'app-hero-reactive',
  templateUrl: './hero-reactive-form.component.html'
})
export class HeroReactiveFormComponent {
  heroForm: FormGroup;
  states = states;

  constructor(private fb: FormBuilder) {
    this.createForm();
  }

  createForm() {
    this.heroForm = this.fb.group({
      name: ['', Validators.required ],
      address: this.fb.group(new Address()),
      power: '',
      sidekick: ''
    });
  }
}
